package com.caisejingyu.whales.home.devices.printer;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * @author GaoGao
 * @date 2015-5-16
 * @description 使用SharePreference存储key&value格式类
 */
public class SpStore {

	private Context mContext;
	private String mSpName;

	public SpStore(Context context, String spName) {
		mContext = context;
		mSpName = spName;
	}

	public void put(String key, String value) {
		SharedPreferences sharePreference = mContext.getSharedPreferences(mSpName, Context.MODE_PRIVATE);
		SharePreferenceBooster.instance().put(sharePreference, key, value);
	}
	
	public void putAsync(String key, String value) {
		SharedPreferences sharePreference = mContext.getSharedPreferences(mSpName, Context.MODE_PRIVATE);
		SharePreferenceBooster.instance().putAsync(sharePreference, key, value);
	}
	
	public String get(String key, String defaultValue) {
		SharedPreferences sharePreference = mContext.getSharedPreferences(mSpName, Context.MODE_PRIVATE);
		String value = SharePreferenceBooster.instance().get(sharePreference, key, defaultValue);
		return value;
	}
	
	public void putBoolean(String key, boolean value) {
		SharedPreferences sharePreference = mContext.getSharedPreferences(mSpName, Context.MODE_PRIVATE);
		SharePreferenceBooster.instance().putBoolean(sharePreference, key, value);
	}
	
	public boolean getBoolean(String key, boolean defaultValue) {
		SharedPreferences sharePreference = mContext.getSharedPreferences(mSpName, Context.MODE_PRIVATE);
		boolean value = SharePreferenceBooster.instance().getBoolean(sharePreference, key, defaultValue);
		return value;
	}
	
	public void putInt(String key, int value) {
		SharedPreferences sharePreference = mContext.getSharedPreferences(mSpName, Context.MODE_PRIVATE);
		SharePreferenceBooster.instance().putInt(sharePreference, key, value);
	}
	
	public int getInt(String key, int defaultValue) {
		SharedPreferences sharePreference = mContext.getSharedPreferences(mSpName, Context.MODE_PRIVATE);
		int value = SharePreferenceBooster.instance().getInt(sharePreference, key, defaultValue);
		return value;
	}
	
}
